textlinedisplaycache: short-circuit y_range invalidation
authorChristian Hergert <chergert@redhat.com>
Sun, 2 Aug 2020 23:35:50 +0000 (16:35 -0700)
committerChristian Hergert <chergert@redhat.com>
Sun, 2 Aug 2020 23:35:50 +0000 (16:35 -0700)
If we have a y==-1 then we are generally invalidating the whole textview.
For this case, we can just discard the entire GtkTextLineDisplay cache.

Fixes #2975

gtk/gtktextlinedisplaycache.c

index fa595644ff6f8af404272438f04b52dec8451184..91ce0d98e4a565c69051cc297c25e8e30c3a24d2 100644 (file)
@@ -663,6 +663,12 @@ gtk_text_line_display_cache_invalidate_y_range (GtkTextLineDisplayCache *cache,
 
   STAT_INC (cache->inval_by_y_range);
 
+  if (y < 0)
+    {
+      gtk_text_line_display_cache_invalidate (cache);
+      return;
+    }
+
   btree = _gtk_text_buffer_get_btree (layout->buffer);
   iter = find_iter_at_at_y (cache, layout, y);